﻿using System;
using System.Windows.Data;
using System.Collections.Generic;

namespace PmuRegistry.Silverlight.Converters
{
	public class StringToPhasorTypeConverter : IValueConverter
	{
		#region IValueConverter Members

		public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			if (value.ToString() == "I")
				return new KeyValuePair<string, string>("I", "Current");
			else if (value.ToString() == "V")
				return new KeyValuePair<string, string>("V", "Voltage");
			else
				throw new ArgumentException("Value not supported as a Phasor Type");
		}

		public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			if (value is KeyValuePair<string, string>)
			{
				return ((KeyValuePair<string, string>)value).Key;
			}
			else
				throw new ArgumentException("Value not supported as a Phasor Type");
		}

		#endregion
	}
}
